package com.leapp.sk.ui.activity.classs

import android.content.Intent
import android.os.Bundle
import android.support.v4.widget.SwipeRefreshLayout
import com.example.mvp.activity.BaseActivityMVP
import com.example.mvp.binder.BaseDataBinder
import com.example.mvp.view.PopupWindowUtil
import com.example.mvp.view.imgselector.ImageSelector
import com.example.util.LKTimeUtil
import com.leapp.sk.bean.AlbumEntity
import com.leapp.sk.bean.ClassAlbumDetialEntity
import com.leapp.sk.binder.BaseBinder
import com.leapp.sk.inter.ImagePathInterface
import com.leapp.sk.util.getResultFile
import com.leapp.sk.viewdelegate.classs.ClassAlbumDetialDelegate

/**
 * 班级相册详情
 * @author  chaohaipeng  on 2018/8/6.
 */
class ClassAlbumDetialActivity :BaseActivityMVP<ClassAlbumDetialDelegate>(), SwipeRefreshLayout.OnRefreshListener, ImagePathInterface {
    val mutableListOf = mutableListOf<ClassAlbumDetialEntity>()
    override fun getArrayImagePath(path: List<String>) {
        val classAlbumDetialEntity = ClassAlbumDetialEntity()
        classAlbumDetialEntity.time=LKTimeUtil.getInstance().formatTime("yyyy.MM.dd",System.currentTimeMillis())
        val mutableListOfIm = mutableListOf<AlbumEntity>()
         for(i in path.indices){
             val albumEntity = AlbumEntity()
             albumEntity.url=path.get(i)
             mutableListOfIm.add(albumEntity)
         }
        classAlbumDetialEntity.image=mutableListOfIm
        mutableListOf.add(0,classAlbumDetialEntity)
        viewDelegate.notifyAdapter()
    }

    override fun onRefresh() {
        viewDelegate.stopSwipRefresh()
    }

    override fun initDate() {

        val classAlbumDetialEntity = ClassAlbumDetialEntity()
        val mutableListOfIm = mutableListOf<AlbumEntity>()
        for (i in 1..6){
            mutableListOfIm.add(AlbumEntity())
        }
        classAlbumDetialEntity.image= mutableListOfIm
        mutableListOf.add(classAlbumDetialEntity)
        viewDelegate.initAdapter(this,mutableListOf,this)

    }

    override fun bindEvenListener() {
    }

    override fun getDelegateClass(): Class<ClassAlbumDetialDelegate> {
        return ClassAlbumDetialDelegate::class.java
    }

    override fun getDataBinder(): BaseDataBinder<*, *> {
        return BaseBinder()
    }

    override fun initView(p0: Bundle?) {
        viewDelegate.setTitle("等你下课日常活动")
    }
    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        getResultFile(requestCode, resultCode, data, this, this)
    }
}